{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "toc": true
   },
   "source": [
    "<h1>大纲<span class=\"tocSkip\"></span></h1>\n",
    "<div class=\"toc\"><ul class=\"toc-item\"></ul></div>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-15T01:16:27.528035Z",
     "start_time": "2018-05-15T01:16:27.522370Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Inputs should be numbers not string\n"
     ]
    }
   ],
   "source": [
    "def probability_range_improved(low_range, high_range, minimum, maximum):\n",
    "\n",
    "    # TODO: check if any of the inputs are strings.\n",
    "    # hint: the python function isinstance() will be useful\n",
    "    if isinstance(low_range,int) and isinstance(high_range,int) and isinstance(maximum,int) and isinstance(minimum,int):\n",
    "        probability = abs(high_range - low_range) / abs(maximum - minimum)\n",
    "        return probability\n",
    "    else:\n",
    "        # print a message to the user and return none\n",
    "        print('Inputs should be numbers not string')\n",
    "        return None\n",
    "\n",
    "probability_range_improved(12,32,134,'340')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def probability_range_improved(low_range, high_range, minimum, maximum):\n",
    "\n",
    "    # TODO: check if any of the inputs are strings.\n",
    "    # hint: the python function isinstance() will be useful\n",
    "    if isinstance(low_range,int) and isinstance(high_range,int) and isinstance(maximum,int) and isinstance(minimum,int):\n",
    "        probability = abs(high_range - low_range) / abs(maximum - minimum)\n",
    "        return probability\n",
    "    else:\n",
    "        # print a message to the user and return none\n",
    "        print('Inputs should be numbers not string')\n",
    "        return None\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "conda all lib",
   "language": "python",
   "name": "base"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  },
  "latex_envs": {
   "LaTeX_envs_menu_present": true,
   "autoclose": false,
   "autocomplete": true,
   "bibliofile": "biblio.bib",
   "cite_by": "apalike",
   "current_citInitial": 1,
   "eqLabelWithNumbers": true,
   "eqNumInitial": 1,
   "hotkeys": {
    "equation": "Ctrl-E",
    "itemize": "Ctrl-I"
   },
   "labels_anchors": false,
   "latex_user_defs": false,
   "report_style_numbering": false,
   "user_envs_cfg": false
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "大纲",
   "title_sidebar": "目录",
   "toc_cell": true,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
